<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div id="app">
  <!-- 传递父事件 -->
  <cpn v-bind:cmovies="movies" :cmessage="message"></cpn>
  <!--  <cpn :cmessage="message"></cpn>-->
</div>
</body>
<template id="cpn">
  <div>
    <ul>
      <li v-for="item in cmovies">{{item}}</li>
    </ul>
    <p>{{cmessage}}</p>
  </div>
</template>
<script src="../js/vue.js"></script>
<script>
  // 父传子 props
  const cpn = {
    template: "#cpn",
    // props: ["cmovies", "cmessage"], // 变量
    props: {
      // // 类型限制
      // cmovies: Array,
      // cmessage: String,
      // 类型限制,提供默认值,以及必传
      cmessage: {
        type: String,
        default: "aaaaaaaaaaaa",
        required: true,
      },
      cmovies: {
        type: Array,
        default() { // 类型是对象或数组时默认值是函数
          return ["111"]; // vue2.5.17以下  v-bind 不支持驼峰,存在驼峰需要用 "-" 连接
        },
      },
    },
    data() {
      return {};
    },
    methods: {},
  }

  let app = new Vue({
    el: "#app",
    data: {
      message: "aaa",
      movies: ["英雄", "无极", "赤壁", "影"],
    },
    components: {
      cpn
    }
  });
</script>
</html>